import { createReducer } from 'redux-immutablejs'
import { fromJS } from 'immutable'
import {
  GET_ORDER_STATUS,GET_ORDER_INFO
} from '../constants/order'



//订单状态(10:待支付 20:待发货 30:待收货 40:退货中 50:退款中 60:纠纷中 80:已关闭 90:完成)
const initOrderStatus=
  {
    title:'Order type',
    selectedIndex:0,
    children:[
    {text:'all orders',status:''},
    {text:'To be paid',status:10},
    {text:'Pending delivery',status:20},
    {text:'Goods to be received',status:30},
    {text:'Abnormal single',status:100}, //售后中
    {text:'Closed',status:80},
    {text:'Completed',status:90},
    ]
  }

export const orderStatus = createReducer(fromJS(initOrderStatus),{
	[GET_ORDER_STATUS]: (state, action) => {
    let data=Object.assign(state.toJS(),{selectedIndex:action.data})
	   return fromJS(data)
	}
})

export const orderInfo = createReducer(fromJS({recv_address:{},goods_list:[]}),{
  [GET_ORDER_INFO]: (state, action) => {
     return fromJS(action.data)
  }
})